home *** CD-ROM | disk | FTP | other *** search
/ HAKERIS 11 / HAKERIS 11.ISO / linux / system / LinuxConsole 0.4 / linuxconsole0.4install-en.iso / opt0.4.lcm / bin / eciconftxt.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2004-02-26  |  24.0 KB  |  784 lines

  1. #!/bin/sh
  2. #
  3. # ECI Linux driver configuration script.
  4. # Same goal as eciconf.sh, but can be run in a terminal / console.
  5. #
  6. # Usage :
  7. #   eciconftxt.sh <file.bin>   change quickly .bin file to sync
  8. #   without parameter : interactive mode for configuration
  9. #
  10. # Author   : FlashCode <flashcode@flashtux.org>
  11. # Creation : 2002/10/06
  12. # Licence  : GPL
  13. #
  14.  
  15. # <CONFIG>
  16. BIN_DIR="/usr/local/bin"
  17. ETC_DIR="/etc"
  18. CONF_DIR="/etc/eciadsl/"
  19. PPPD_DIR="/etc/ppp"
  20. VERSION=""
  21. # </CONFIG>
  22.  
  23. if [ "$1" == "--version" -o "$1" == "-v" ]; then
  24.     echo "$VERSION"
  25.     exit 0
  26. fi
  27.  
  28. tmpbin=/tmp/binfile.tmp
  29. previous="Previous setting"
  30.  
  31. if [ $UID -ne 0 ]; then
  32.     echo -e "This script must be run as root.\nType in root password, please."
  33.     su  - -c  "DISPLAY=$DISPLAY PATH=$PATH  $0  $*"
  34.     exit 1
  35. fi
  36.  
  37. if [ -s "$CONF_DIR/eciadsl.conf" ]; then
  38.     prev_vpi=`grep -E "^[ \t]*VPI[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  39.     prev_vci=`grep -E "^[ \t]*VCI[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  40.     prev_vid1=`grep -E "^[ \t]*VID1[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  41.     prev_pid1=`grep -E "^[ \t]*PID1[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  42.     prev_vid2=`grep -E "^[ \t]*VID2[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  43.     prev_pid2=`grep -E "^[ \t]*PID2[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  44.     prev_mode=`grep -E "^[ \t]*MODE[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  45.     prev_firmware=`grep -E "^[ \t]*FIRMWARE[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  46.     prev_synch=`grep -E "^[ \t]*SYNCH[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  47.     prev_staticip=`grep -E "^[ \t]*STATICIP[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  48.     prev_gateway=`grep -E "^[ \t]*GATEWAY[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  49.     prev_use_staticip=`grep -E "^[ \t]*USE_STATICIP[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  50.     prev_use_dhcp=`grep -E "^[ \t]*USE_DHCP[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -d " \t"`
  51.     prev_modem=`grep -E "^[ \t]*MODEM[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  52.     prev_provider=`grep -E "^[ \t]*PROVIDER[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  53.     prev_dns1=`grep -E "^[ \t]*DNS1[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  54.     prev_dns2=`grep -E "^[ \t]*DNS2[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  55.     prev_pppd_user=`grep -E "^[ \t]*PPPD_USER[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  56.     prev_pppd_passwd=`grep -E "^[ \t]*PPPD_PASSWD[ \t]*=" "$CONF_DIR/eciadsl.conf" | tail -1 | cut -f 2 -d '=' | tr -s "\t" " "`
  57. fi
  58.  
  59. case "$1" in
  60. "@menu@")
  61.     choice_ok=0
  62.     echo $2 | grep -E "^[^|]+(\|[^|]+)*\|[^|]+$" > /dev/null 2>&1
  63.     if [ $? -ne 0 ]; then
  64.         echo -e "*** internal error: invalid menu\n$2"
  65.         exit 255
  66.     fi
  67.     while [ $choice_ok -eq 0 ]; do
  68.         item=$(echo $2 | cut -f 1 -d '|')
  69.         echo -e "$item:\n"
  70.         i=0
  71.         fin=0
  72.         possible="|"
  73.         while [ $fin -eq 0 ]; do
  74.             i=$(expr $i + 1)
  75.             item=$(echo $2 | cut -f `expr $i + 1` -d '|')
  76.             if [ -n "$item" ]; then
  77.                 echo "$i) $item"
  78.                 possible="$possible$i|"
  79.             else
  80.                 fin=1
  81.             fi
  82.         done
  83.         i=$(expr $i - 1)
  84.         echo -en "\nEnter your choice (1-$i, default is 1): "
  85.         read choice_menu
  86.         if [ -z "$choice_menu" ]; then
  87.             choice_menu=1
  88.         fi
  89.         echo $possible | grep "$choice_menu" > /dev/null 2>&1
  90.         if [ $? -eq 0 ]; then
  91.             choice_ok=1
  92.         else
  93.             echo -e "** Incorrect choice, try again\n"
  94.         fi
  95.     done
  96.     exit $choice_menu
  97.     ;;
  98.  
  99. "@bin@")
  100.     echo
  101.     fichiers_bin=""
  102.     for bin in $(find "$CONF_DIR" -name "*.bin" | grep -v "firmware"); do
  103.         fichiers_bin="$fichiers_bin|$bin"
  104.     done
  105.     if [ -z "$fichiers_bin" ]; then
  106.         echo "WARNING: no synch .bin file found in $CONF_DIR or subdirectories"
  107.         echo "Please check your driver installation!"
  108.         if [ -n "$prev_synch" ]; then
  109.             echo "Previous selection kept"
  110.             echo "$prev_synch" > $tmpbin
  111.             exit 0
  112.         else
  113.             echo "** skipping synch .bin selection"
  114.             :> $tmpbin
  115.             exit 255
  116.         fi
  117.     fi
  118.     if [ -n "$prev_synch" ]; then
  119.         fichiers_bin="|$previous ($prev_synch)$fichiers_bin"
  120.     fi
  121.     fichiers_bin="Select your .bin file for synch$fichiers_bin"
  122.     $0 @menu@ "$fichiers_bin"
  123.     ret=$?
  124.     test $ret -eq 255 && exit 255
  125.     bin=$(expr $ret + 1)
  126.     echo "$(echo $fichiers_bin | cut -f $bin -d '|')" > $tmpbin
  127.     exit 0
  128.     ;;
  129.  
  130. "")
  131.     menu1="Your choice|Configure all settings|Remove dabusb module|Change synch .bin file"
  132.  
  133.     if [ ! -d $CONF_DIR ]; then
  134.         echo -e "*** config directory not found\n"
  135.         exit 1
  136.     fi
  137.  
  138.     OLDIFS="$IFS"
  139.     IFS="
  140. "
  141.     providers_db="$CONF_DIR/providers.db"
  142.     providers="Select your provider"
  143.     servers_dns1="*"
  144.     servers_dns2="*"
  145.     if [ -n "$prev_provider" -a -n "$prev_dns1" -o -n "$prev_dns2" ]; then
  146.         test -z "$prev_dns1" && prev_dns1="?"
  147.         test -z "$prev_dns2" && prev_dns2="?"
  148.         # if the saved provider label is known but the saved DNS don't match,
  149.         # assume Other and keep DNS
  150.         dns1_="$(grep -v -E "^[ \t]*#" "$providers_db" | grep "$prev_provider" | tr -s "\t" "|" | cut -d '|' -f 2)"
  151.         dns2_="$(grep -v -E "^[ \t]*#" "$providers_db" | grep "$prev_provider" | tr -s "\t" "|" | cut -d '|' -f 3)"
  152.         if [ "$prev_provider" != "Other" -a "$dns1_" != "$prev_dns1" -o "$dns2_" != "$prev_dns2" ]; then
  153.             prev_provider="Other"
  154.             servers_dns1="$servers_dns1|$prev_dns1"
  155.             servers_dns2="$servers_dns2|$prev_dns2"
  156.         else
  157.             servers_dns1="$servers_dns1|$dns1_"
  158.             servers_dns2="$servers_dns2|$dns2_"
  159.         fi
  160.         providers="$providers|$previous ($prev_provider)"
  161.     fi
  162.     for LINE in $(grep -v -E "^[ \t]*#" "$providers_db" | tr -s "\t" "|" | cut -d '|' -f 1); do
  163.         providers="$providers|$LINE"
  164.     done
  165.     for LINE in $(grep -v -E "^[ \t]*#" "$providers_db" | tr -s "\t" "|" | cut -d '|' -f 2); do
  166.         servers_dns1="$servers_dns1|$LINE"
  167.     done
  168.     for LINE in $(grep -v -E "^[ \t]*#" "$providers_db"| tr -s "\t" "|" | cut -d '|' -f 3); do
  169.         servers_dns2="$servers_dns2|$LINE"
  170.     done
  171.     providers="$providers|Other"
  172.     servers_dns1="$servers_dns1|?"
  173.     servers_dns2="$servers_dns2|?"
  174.  
  175.     modems_db="$CONF_DIR/modems.db"
  176.     modems="Select your modem"
  177.     vid1pid1="*"
  178.     vid2pid2="*"
  179.     if [ -n "$prev_modem" -a -n "$prev_vid1" -o -n "$prev_pid1" -o -n "$prev_vid2" -o -n "$prev_pid2" ]; then
  180.         test -z "$prev_vid1" && prev_vid1="????"
  181.         test -z "$prev_pid1" && prev_pid1="????"
  182.         test -z "$prev_vid2" && prev_vid2="????"
  183.         test -z "$prev_pid2" && prev_pid2="????"
  184.         # if the saved modem label is known but the saved VIDPID don't match,
  185.         # assume Other and keep VIDPID
  186.         vid1_="$(grep -v -E "^[ \t]*#" "$modems_db" | grep "$prev_modem" | tr -s "\t" "|" | cut -d '|' -f 2)"
  187.         pid1_="$(grep -v -E "^[ \t]*#" "$modems_db" | grep "$prev_modem" | tr -s "\t" "|" | cut -d '|' -f 3)"
  188.         vid2_="$(grep -v -E "^[ \t]*#" "$modems_db" | grep "$prev_modem" | tr -s "\t" "|" | cut -d '|' -f 4)"
  189.         pid2_="$(grep -v -E "^[ \t]*#" "$modems_db" | grep "$prev_modem" | tr -s "\t" "|" | cut -d '|' -f 5)"
  190.         if [ "$prev_modem" != "Other" -a "$vid1_" != "$prev_vid1" -o "$pid1_" != "$prev_pid1" -o "$vid2_" != "$prev_vid2" -o "$pid2_" != "$prev_pid2" ]; then
  191.             prev_modem="Other"
  192.             vid1pid1="$vid1pid1|$prev_vid1$prev_pid1"
  193.             vid2pid2="$vid2pid2|$prev_vid2$prev_pid2"
  194.         else
  195.             vid1pid1="$vid1pid1|$vid1_$pid1_"
  196.             vid2pid2="$vid2pid2|$vid2_$pid2_"
  197.         fi
  198.         modems="$modems|$previous ($prev_modem)"
  199.     fi
  200.     for LINE in $(grep -v -E "^[ \t]*#" "$modems_db" | tr -s "\t" "|" | cut -d "|" -f 1); do
  201.         modems="$modems|$LINE"
  202.     done
  203.     for LINE in $(grep -v -E "^[ \t]*#" "$modems_db" | tr -s "\t" "|" | cut -d "|" -f 2-3 | tr -d "| "); do
  204.         vid1pid1="$vid1pid1|$LINE"
  205.     done
  206.     for LINE in $(grep -v -E "^[ \t]*#" "$modems_db" | tr -s "\t" "|" | cut -d "|" -f 4-5 | tr -d "| "); do
  207.         vid2pid2="$vid2pid2|$LINE"
  208.     done
  209.     IFS="$OLDIFS"
  210.     modems="$modems|Other"
  211.     vid1pid1="$vid1pid1|????????"
  212.     vid2pid2="$vid2pid2|????????"
  213.  
  214.     echo -e "\n===== Welcome to the Eci Adsl Linux driver configuration =====\n"
  215.     echo -e "At any time, press Ctrl+C to quit this script without saving modifications.\n"
  216.     echo -e "Tip: you can run eciconftxt.sh with a .bin file as parameter to change\nyour .bin quickly.\n"
  217.  
  218.     $0 @menu@ "$menu1"
  219.     ret=$?
  220.     test $ret -eq 255 && exit 1
  221.     config=$ret
  222.  
  223.     ### Global Eci Adsl configuration ###
  224.  
  225.     if [ $config -eq 1 ]; then
  226.         echo -e "\n===> Eci Adsl driver setup <===\n"
  227.  
  228.         user=""
  229.         while [ -z "$user" ]; do
  230.             if [ -n "$prev_pppd_user" ]; then
  231.                 echo "Current user name is: $prev_pppd_user"
  232.                 TMP=", press ENTER to keep the previous one"
  233.             else
  234.                 TMP=""
  235.             fi
  236.             echo -n "Type in your user name (given by your provider$TMP): "
  237.             read user
  238.             if [ -z "$user" -a -n "$prev_pppd_user" ]; then
  239.                 user="$prev_pppd_user"
  240.                 echo "* user name unchanged"
  241.             fi
  242.         done
  243.  
  244.         echo
  245.         pwdmatch=0
  246.         while [ $pwdmatch -eq 0 ]; do
  247.             if [ -n "$prev_pppd_passwd" ]; then
  248.                 echo "Current password is: $prev_pppd_passwd"
  249.                 TMP=", press ENTER to keep the previous one"
  250.             else
  251.                 TMP=""
  252.             fi
  253.             stty -echo
  254.             password1=""
  255.             while [ -z "$password1" ]; do
  256.                 echo -n "Type in your password (given by your provider$TMP): "
  257.                 read password1
  258.                 echo
  259.                 if [ -z "$password1" -a -n "$prev_pppd_passwd" ]; then
  260.                     password1="$prev_pppd_passwd"
  261.                     echo "* password unchanged"
  262.                 fi
  263.             done
  264.             if [ "$password1" == "$prev_pppd_passwd" ]; then
  265.                 password2="$password1"
  266.             else
  267.                 password2=""
  268.                 while [ -z "$password2" ]; do
  269.                     echo -n "Type in your password again (for verification$TMP): "
  270.                     read password2
  271.                     echo
  272.                 done
  273.             fi
  274.             stty echo
  275.             if [ "$password1" == "$password2" ]; then
  276.                 pwdmatch=1
  277.             else
  278.                 echo -e "** passwords don't match, try again\n"
  279.             fi
  280.         done
  281.  
  282.         echo
  283.         $0 @menu@ "$providers"
  284.         ret=$?
  285.         test $ret -eq 255 && exit 1
  286.         provider=$(expr $ret + 1)
  287.         dns1="$(echo $servers_dns1 | cut -f $provider -d '|')"
  288.         dns2="$(echo $servers_dns2 | cut -f $provider -d '|')"
  289.  
  290.         echo
  291.         echo "If your provider was not listed (or if you want to overwrite"
  292.         echo "defaults), you can type in your own DNS servers:"
  293.         echo
  294.  
  295.         echo -n "DNS1 currently "
  296.         if [ "$dns1" == "?" ]; then
  297.             echo "unset"
  298.             TMP="skip"
  299.         else
  300.             echo "set to $dns1"
  301.             TMP="keep current value"
  302.         fi
  303.         i_dns1=""
  304.         while [ -z "$i_dns1" ]; do
  305.             echo -n "Type in an IP for DNS1 (press ENTER to $TMP): "
  306.             read i_dns1
  307.             if [ -z "$i_dns1" ]; then
  308.                 if [ "$dns1" == "?" ]; then
  309.                     dns1=""
  310.                 else
  311.                     echo "* DNS1 unchanged"
  312.                 fi
  313.                 break
  314.             else
  315.                 echo $i_dns1 | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}$" > /dev/null 2>&1
  316.                 if [ $? -ne 0 ]; then
  317.                     i_dns1=""
  318.                     echo -e "** invalid IP for DNS1, please retry\n"
  319.                 else
  320.                     if [ "$i_dns1" != "$dns1" ]; then
  321.                         provider="Other"
  322.                         dns1="$i_dns1"
  323.                     fi
  324.                 fi
  325.             fi
  326.         done
  327.  
  328.         echo
  329.         i_dns2=""
  330.         echo -n "DNS2 currently "
  331.         if [ "$dns2" == "?" ]; then
  332.             echo "unset"
  333.             TMP="skip"
  334.         else
  335.             echo "set to $dns2"
  336.             TMP="keep current value"
  337.         fi
  338.         while [ -z "$i_dns2" ]; do
  339.             echo -n "Type in an IP for DNS2 (press ENTER to $TMP): "
  340.             read i_dns2
  341.             if [ -z "$i_dns2" ]; then
  342.                 if [ "$dns2" == "?" ]; then
  343.                     dns2=""
  344.                 else
  345.                     echo "* DNS2 unchanged"
  346.                 fi
  347.                 break
  348.             else
  349.                 echo $i_dns2 | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}$" > /dev/null 2>&1
  350.                 if [ $? -ne 0 ]; then
  351.                     i_dns2=""
  352.                     echo -e "** invalid IP for DNS2, please retry\n"
  353.                 else
  354.                     if [ "$i_dns2" != "$dns2" ]; then
  355.                         provider="Other"
  356.                         dns2="$i_dns2"
  357.                     fi
  358.                 fi
  359.             fi
  360.         done
  361.  
  362.         echo
  363.         echo "Enter now your VPI/VCI (depending on your provider/country)"
  364.         echo "Example for France: 8 35  (VPI=8, VCI=35)"
  365.         echo "These values correspond to the number dialed under Windows."
  366.         echo
  367.         echo -n "VPI currently "
  368.         if [ -z "$prev_vpi" ]; then
  369.             echo "unset"
  370.             TMP=""
  371.         else
  372.             echo "set to $prev_vpi"
  373.             TMP=", press ENTER to keep the previous one"
  374.         fi
  375.         vpi=""
  376.         while [ -z "$vpi" ]; do
  377.             echo -n "Type in your VPI (given by your provider$TMP): "
  378.             read vpi
  379.             if [ -n "$prev_vpi" -a -z "$vpi" ]; then
  380.                 vpi="$prev_vpi"
  381.                 echo "* VPI unchanged"
  382.             else
  383.                 echo $vpi | grep -E "^[0-9]+$" > /dev/null 2>&1
  384.                 if [ $? -ne 0 ]; then
  385.                     vpi=""
  386.                     echo -e "** invalid VPI, please enter it again\n"
  387.                 else
  388.                     if [ $vpi -ge 4096 ]; then
  389.                         vpi=""
  390.                         echo -e "** VPI not in range [0-4095], please enter it again\n"
  391.                     fi
  392.                 fi
  393.             fi
  394.         done
  395.         echo
  396.         echo -n "VCI currently "
  397.         if [ -z "$prev_vci" ]; then
  398.             echo "unset"
  399.             TMP=""
  400.         else
  401.             echo "set to $prev_vci"
  402.             TMP=", press ENTER to keep the previous one"
  403.         fi
  404.         vci=""
  405.         while [ -z "$vci" ]; do
  406.             echo -n "Type in your VCI (given by your provider$TMP): "
  407.             read vci
  408.             if [ -n "$prev_vci" -a -z "$vci" ]; then
  409.                 vci="$prev_vci"
  410.                 echo "* VCI unchanged"
  411.             else
  412.                 echo $vci | grep -E "^[0-9]+$" > /dev/null 2>&1
  413.                 if [ $? -ne 0 ]; then
  414.                     vci=""
  415.                     echo -e "** invalid VCI, please enter it again\n"
  416.                 else
  417.                     if [ $vci -ge 65536 ]; then
  418.                         vci=""
  419.                         echo -e "** VCI not in range [0-65535], please enter it again\n"
  420.                     fi
  421.                 fi
  422.             fi
  423.         done
  424.  
  425.         echo
  426.         $0 @menu@ "$modems"
  427.         ret=$?
  428.         test $ret -eq 255 && exit 1
  429.         modem=$(expr $ret + 1)
  430.         vid1="$(echo $vid1pid1 | cut -f $modem -d '|' | cut -c 1-4)"
  431.         pid1="$(echo $vid1pid1 | cut -f $modem -d '|' | cut -c 5-8)"
  432.         vid2="$(echo $vid2pid2 | cut -f $modem -d '|' | cut -c 1-4)"
  433.         pid2="$(echo $vid2pid2 | cut -f $modem -d '|' | cut -c 5-8)"
  434.  
  435.         echo
  436.         echo "If your modem was not listed (or if you want to overwrite defaults),"
  437.         echo "you can enter your own VID1/PID1/VID2/PID2 (use probe_device.sh to"
  438.         echo "get them):"
  439.  
  440.         echo
  441.         echo -n "VID1 currently "
  442.         if [ "$vid1" == "????" ]; then
  443.             echo "unset"
  444.             TMP=""
  445.         else
  446.             echo "set to $vid1"
  447.             TMP=", press ENTER to keep current value"
  448.         fi
  449.         i_vid1=""
  450.         while [ -z "$i_vid1" ]; do
  451.             echo -n "Type in a VID1 (4-digit hexadecimal$TMP): "
  452.             read i_vid1
  453.             if [ -z "$i_vid1" ]; then
  454.                 if [ "$vid1" != "????" ]; then
  455.                     echo "* VID1 unchanged"
  456.                     break
  457.                 else
  458.                     echo -e "** VID1 still unset, please enter a value\n"
  459.                 fi
  460.             else
  461.                 echo $i_vid1 | grep -E "^([0-9A-Fa-f]{4})$" > /dev/null 2>&1
  462.                 if [ $? -eq 0 ]; then
  463.                     vid1="$i_vid1"
  464.                 else
  465.                     i_vid1=""
  466.                     echo -e "** invalid VID1, please enter it again\n"
  467.                 fi
  468.             fi
  469.         done
  470.  
  471.         echo
  472.         echo -n "PID1 currently "
  473.         if [ "$pid1" == "????" ]; then
  474.             echo "unset"
  475.             TMP=""
  476.         else
  477.             echo "set to $pid1"
  478.             TMP=", press ENTER to keep current value"
  479.         fi
  480.         i_pid1=""
  481.         while [ -z "$i_pid1" ]; do
  482.             echo -n "Type in a PID1 (4-digit hexadecimal$TMP): "
  483.             read i_pid1
  484.             if [ -z "$i_pid1" ]; then
  485.                 if [ "$pid1" != "????" ]; then
  486.                     echo "* PID1 unchanged"
  487.                     break
  488.                 else
  489.                     echo -e "** PID1 still unset, please enter a value\n"
  490.                 fi
  491.             else
  492.                 echo $i_pid1 | grep -E "^([0-9A-Fa-f]{4})$" > /dev/null 2>&1
  493.                 if [ $? -eq 0 ]; then
  494.                     pid1="$i_pid1"
  495.                 else
  496.                     i_pid1=""
  497.                     echo -e "** invalid PID1, please enter it again\n"
  498.                 fi
  499.             fi
  500.         done
  501.  
  502.         echo
  503.         echo -n "VID2 currently "
  504.         if [ "$vid2" == "????" ]; then
  505.             echo "unset"
  506.             TMP=""
  507.         else
  508.             echo "set to $vid2"
  509.             TMP=", press ENTER to keep current value"
  510.         fi
  511.         i_vid2=""
  512.         while [ -z "$i_vid2" ]; do
  513.             echo -n "Type in a VID2 (4-digit hexadecimal$TMP): "
  514.             read i_vid2
  515.             if [ -z "$i_vid2" ]; then
  516.                 if [ "$vid2" != "????" ]; then
  517.                     echo "* VID2 unchanged"
  518.                     break
  519.                 else
  520.                     echo -e "** VID2 still unset, please enter a value\n"
  521.                 fi
  522.             else
  523.                 echo $i_vid2 | grep -E "^([0-9A-Fa-f]{4})$" > /dev/null 2>&1
  524.                 if [ $? -eq 0 ]; then
  525.                     vid2="$i_vid2"
  526.                 else
  527.                     i_vid2=""
  528.                     echo -e "** invalid VID2, please enter it again\n"
  529.                 fi
  530.             fi
  531.         done
  532.  
  533.         echo
  534.         echo -n "PID2 currently "
  535.         if [ "$pid2" == "????" ]; then
  536.             echo "unset"
  537.             TMP=""
  538.         else
  539.             echo "set to $pid2"
  540.             TMP=", press ENTER to keep current value"
  541.         fi
  542.         i_pid2=""
  543.         while [ -z "$i_pid2" ]; do
  544.             echo -n "Type in a PID2 (4-digit hexadecimal$TMP): "
  545.             read i_pid2
  546.             if [ -z "$i_pid2" ]; then
  547.                 if [ "$pid2" != "????" ]; then
  548.                     echo "* PID2 unchanged"
  549.                     break
  550.                 else
  551.                     echo -e "** PID2 still unset, please enter a value\n"
  552.                 fi
  553.             else
  554.                 echo $i_pid2 | grep -E "^([0-9A-Fa-f]{4})$" > /dev/null 2>&1
  555.                 if [ $? -eq 0 ]; then
  556.                     pid2="$i_pid2"
  557.                 else
  558.                     i_pid2=""
  559.                     echo -e "** invalid PID2, please enter it again\n"
  560.                 fi
  561.             fi
  562.         done
  563.  
  564.         $0 @bin@
  565.         ret=$?
  566.         binfile=$(cat $tmpbin)
  567.         rm -rf $tmpbin > /dev/null
  568.  
  569.         OLDIFS="$IFS"
  570.         IFS="
  571. "
  572.         modes="Select your PPP mode (use the DEFAULT one if you don't know what this means)"
  573.         if [ -n "$prev_mode" ]; then
  574.             modes="$modes|$previous ($prev_mode)"
  575.         fi
  576.         for LINE in $($BIN_DIR/pppoeci --modes 2>&1 | cut -d ' ' -f 1); do
  577.             modes="$modes|$LINE"
  578.         done
  579.         modes="$modes"
  580.         IFS="$OLDIFS"
  581.         $0 @menu@ "$modes"
  582.         ret=$?
  583.         test $ret -eq 255 && exit 1
  584.         mode=$(expr $ret + 1)
  585.  
  586.         echo
  587.         if [ -n "$prev_use_dhcp" ]; then
  588.             echo -n "In current config, DHCP is "
  589.             if [ "$prev_use_dhcp" == "yes" ]; then
  590.                 echo "enabled"
  591.             else
  592.                 echo "disabled"
  593.             fi
  594.             TMP=" or press ENTER to keep current value"
  595.         else
  596.             TMP=""
  597.         fi
  598.         echo "Is DHCP used by your provider (MOST users should say NO)? "
  599.         use_dhcp=""
  600.         while [ -z "$use_dhcp" ]; do
  601.             echo -n "(y/n$TMP) "
  602.             read use_dhcp
  603.             case "$use_dhcp" in
  604.             y*|Y*)    use_dhcp="yes"
  605.                     ;;
  606.             n*|N*)    use_dhcp="no"
  607.                     ;;
  608.             "")        if [ -n "$prev_use_dhcp" ]; then
  609.                         use_dhcp="$prev_use_dhcp"
  610.                         echo "* DHCP usage unchanged"
  611.                     else
  612.                         use_dhcp="no"
  613.                     fi
  614.                     ;;
  615.             *)        use_dhcp=""
  616.                     echo -e "** invalid answer, try again\n"
  617.                     ;;
  618.             esac
  619.         done
  620.  
  621.         if [ "$use_dhcp" != "yes" ]; then
  622.             echo
  623.             if [ -n "$prev_use_staticip" ]; then
  624.                 echo -n "In current config, static IP is "
  625.                 if [ "$prev_use_staticip" == "yes" ]; then
  626.                     echo "used"
  627.                     TMP=" or press ENTER to keep current setting"
  628.                 else
  629.                     echo "not used"
  630.                     TMP=""
  631.                 fi
  632.             else
  633.                 TMP=""
  634.             fi
  635.             echo "Did you get a static IP from your provider (MOST users should say NO)? "
  636.             use_staticip=""
  637.             while [ -z "$use_staticip" ]; do
  638.                    echo -n "(y/n$TMP) "
  639.                 read use_staticip
  640.                 case "$use_staticip" in
  641.                 y*|Y*)    use_staticip="yes"
  642.                         ;;
  643.                 n*|N*)    use_staticip="no"
  644.                         ;;
  645.                 "")        if [ -n "$prev_use_staticip" ]; then
  646.                             use_staticip="$prev_use_staticip"
  647.                             echo "* static IP usage unchanged"
  648.                         else
  649.                             use_staticip="no"
  650.                         fi
  651.                         ;;
  652.                 *)        use_staticip=""
  653.                         echo -e "** invalid answer, try again\n"
  654.                         ;;
  655.                 esac
  656.             done
  657.  
  658.             if [ "$use_staticip" == "yes" ]; then
  659.                 if [ -n "$prev_staticip" ]; then
  660.                     TMP=" (press ENTER to use $prev_staticip)"
  661.                 else
  662.                     TMP=""
  663.                 fi
  664.                 echo
  665.                 echo -n "Type in your static IP$TMP: "
  666.                 staticip=""
  667.                 while [ -z "$staticip" ]; do
  668.                     read staticip
  669.                     case "$staticip" in
  670.                     "")        if [ -n "$prev_staticip" ]; then
  671.                                 staticip="$prev_staticip"
  672.                                 echo "* static IP unchanged"
  673.                             fi
  674.                             ;;
  675.                     *)        echo "$staticip" | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}$" > /dev/null 2>&1 
  676.                             if [ $? -ne 0 ]; then
  677.                                 staticip=""
  678.                             fi
  679.                             ;;
  680.                     esac
  681.                     test -z "$staticip" && echo -n "** invalid static IP, try again $TMP: "
  682.                 done
  683.  
  684.                 if [ -n "$prev_gateway" ]; then
  685.                     TMP=" (press ENTER to use $prev_gateway)"
  686.                 else
  687.                     TMP=""
  688.                 fi
  689.                 echo
  690.                 echo -n "Type in your provider's gateway IP$TMP: "
  691.                 gateway=""
  692.                 while [ -z "$gateway" ]; do
  693.                     read gateway
  694.                     case "$gateway" in
  695.                     "")        if [ -n "$gateway" ]; then
  696.                                 gateway="$prev_gateway"
  697.                                 echo "* gateway unchanged"
  698.                             fi
  699.                             ;;
  700.                     *)        echo "$gateway" | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}$" > /dev/null 2>&1 
  701.                             if [ $? -ne 0 ]; then
  702.                                 gateway=""
  703.                             fi
  704.                             ;;
  705.                     esac
  706.                     test -z "$gateway" && echo -n "** invalid gateway IP, try again $TMP: "
  707.                 done
  708.             fi
  709.         fi
  710.  
  711.         # extract values from lists
  712.         mode="$(echo $modes | cut -f $mode -d '|')"
  713.         modem="$(echo $modems | cut -f $modem -d '|')"
  714.         test "$provider" != "Other" && provider="$(echo $providers | cut -f $provider -d '|')"
  715.         # remove "previous ()" is necessary
  716.         echo "$provider" | grep -E "^$previous \(.+\)$" > /dev/null 2>&1 && \
  717.             provider=$(echo "$provider" | cut -d '(' -f 2 | cut -d ')' -f 1)
  718.         echo "$modem" | grep -E "^$previous \(.+\)$" > /dev/null 2>&1 && \
  719.             modem=$(echo "$modem" | cut -d '(' -f 2 | cut -d ')' -f 1)
  720.         echo "$binfile" | grep -E "^$previous \(.+\)$" > /dev/null 2>&1 && \
  721.             binfile=$(echo "$binfile" | cut -d '(' -f 2 | cut -d ')' -f 1)
  722.         echo "$mode" | grep -E "^$previous \(.+\)$" > /dev/null 2>&1 && \
  723.             mode=$(echo "$mode" | cut -d '(' -f 2 | cut -d ')' -f 1)
  724.         echo
  725.         echo "==== Configuration will be created with these values :"
  726.         echo
  727.         echo "  + User          : $user"
  728.         echo "  + Password      : (hidden)"
  729.         echo "  + Provider      : $provider"
  730.         echo "      DNS 1       : $dns1"
  731.         echo "      DNS 2       : $dns2"
  732.         echo "  + VPI/VCI       : $vpi/$vci"
  733.         echo "  + Modem         : $modem"
  734.         echo "      VID1/PID1   : $vid1/$pid1"
  735.         echo "      VID2/PID2   : $vid2/$pid2"
  736.         echo "  + .bin file     : $binfile"
  737.         echo "  + PPP mode      : $mode"
  738.         echo "  + use DHCP      : $use_dhcp"
  739.         echo "  + use static IP : $use_dhcp"
  740.         if [ "$use_staticip" == "yes" ]; then
  741.             echo "    static IP     : $staticip"
  742.             echo "      gateway     : $gateway"
  743.         fi
  744.         echo
  745.         echo "Press ENTER to create config files or Ctrl+C to exit now without saving."
  746.         read quitte
  747.  
  748.         $BIN_DIR/makeconfig "$mode" "$user" "$password1" "$BIN_DIR/pppoeci" "$dns1" "$dns2" \
  749.             "$vpi" "$vci" "$vid1$pid1" "$vid2$pid2" "$binfile" "$firmware" \
  750.             "$staticip" "$gateway" "$use_staticip" "$use_dhcp" "$modem" "$provider"
  751.         if [ $? -eq 0 ]; then
  752.             echo
  753.             echo "==== eciconftxt.sh: Configuration updated with success !"
  754.             echo "You can now run startmodem (as root) to connect to the internet."
  755.         else
  756.             echo "*** makeconfig reports error(s), please fix the problem and run eciconftxt.sh again."
  757.         fi
  758.         echo
  759.     elif [ $config -eq 2 ]; then
  760.         echo
  761.         echo "Please unplug your modem and then press ENTER"
  762.         read pause
  763.         remove_dabusb
  764.         echo
  765.     else
  766.         $0 @bin@
  767.         ret=$?
  768.         binfile=$(cat $tmpbin)
  769.         rm -rf $tmpbin > /dev/null
  770.         test $ret -eq 255 && exit 1
  771.         echo
  772.         $0 $binfile
  773.         echo
  774.     fi
  775.     ;;
  776.  
  777. *)
  778.     # .bin change
  779.     $BIN_DIR/makeconfig --synch "$1"
  780.     exit $?
  781.     ;;
  782. esac
  783. exit 0
  784.